import { ItemData } from "../../../resource/info/ItemData";
import { ItemConfig } from "../../../resource/ItemConfig";
import { TItemWeapon } from "../../../../../Message/Db/Tables/TItemWeapon";
import { EPetLifeStyle } from "../../../../../Message/Public/EPetLifeStyle";
import { EJewel } from "../../../../../Message/Public/EJewel";
import { TPetLifestyleHunt } from "../../../../../Message/Db/Tables/TPetLifestyleHunt";
import { ColorConfig } from "../../../resource/ColorConfig";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { PetMingJuWindow } from "../ming/PetMingJuWindow";
import { Cache } from "../../../cache/Cache";
import { FlyToNavbarTool } from "../../award/FlyToNavbarTool";
import { NumAddEffect } from "../../effect/NumAddEffect";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
type int = number;
//class PetMingUtil
    
    export  class PetMingUtil
    {
        

        public static getAttrByType(arg1: int, arg2: ItemData): int
        {
            var loc1=0;
            var loc3=null;
            var loc2;
            if (loc2 = ItemConfig.instance.getInfoByCode(arg2.itemCode)) 
            {
                if (loc3 = loc2.extend as TItemWeapon) 
                {
                    if (arg1 != EPetLifeStyle._EPetLifeStyleAgile) 
                    {
                        if (arg1 != EPetLifeStyle._EPetLifeStyleBlock) 
                        {
                            if (arg1 != EPetLifeStyle._EPetLifeStyleBrains) 
                            {
                                if (arg1 == EPetLifeStyle._EPetLifeStyleHabitus) 
                                {
                                    loc1 = loc3.habitus;
                                }
                            }
                            else 
                            {
                                loc1 = loc3.brains;
                            }
                        }
                        else 
                        {
                            loc1 = loc3.block;
                        }
                    }
                    else 
                    {
                        loc1 = loc3.agile;
                    }
                    if (arg1 != EPetLifeStyle._EPetLifeStyleHit) 
                    {
                        if (arg1 != EPetLifeStyle._EPetLifeStyleJouk) 
                        {
                            if (arg1 != EPetLifeStyle._EPetLifeStyleLife) 
                            {
                                if (arg1 == EPetLifeStyle._EPetLifeStyleMagicAttack) 
                                {
                                    loc1 = loc3.magicAttack;
                                }
                            }
                            else 
                            {
                                loc1 = loc3.life;
                            }
                        }
                        else 
                        {
                            loc1 = loc3.jouk;
                        }
                    }
                    else 
                    {
                        loc1 = loc3.hit;
                    }
                    if (arg1 != EPetLifeStyle._EPetLifeStyleMagicCrit) 
                    {
                        if (arg1 != EPetLifeStyle._EPetLifeStyleMagicDefense) 
                        {
                            if (arg1 != EPetLifeStyle._EPetLifeStyleMana) 
                            {
                                if (arg1 != EPetLifeStyle._EPetLifeStylePass) 
                                {
                                    if (arg1 == EPetLifeStyle._EPetLifeStylePhysicalAttack) 
                                    {
                                        loc1 = loc3.physicalAttack;
                                    }
                                }
                                else 
                                {
                                    loc1 = loc3.pass;
                                }
                            }
                            else 
                            {
                                loc1 = loc3.mana;
                            }
                        }
                        else 
                        {
                            loc1 = loc3.magicDefense;
                        }
                    }
                    else 
                    {
                        loc1 = loc3.magicCrit;
                    }
                    if (arg1 != EPetLifeStyle._EPetLifeStylePhysicalCrit) 
                    {
                        if (arg1 != EPetLifeStyle._EPetLifeStylePhysicalDefense) 
                        {
                            if (arg1 != EPetLifeStyle._EPetLifeStylePower) 
                            {
                                if (arg1 != EPetLifeStyle._EPetLifeStyleRelief) 
                                {
                                    if (arg1 != EPetLifeStyle._EPetLifeStyleSpeededUp) 
                                    {
                                        if (arg1 == EPetLifeStyle._EPetLifeStyleToughness) 
                                        {
                                            loc1 = loc3.toughness;
                                        }
                                    }
                                    else 
                                    {
                                        loc1 = loc3.speededUp;
                                    }
                                }
                                else 
                                {
                                    loc1 = loc3.relief;
                                }
                            }
                            else 
                            {
                                loc1 = loc3.power;
                            }
                        }
                        else 
                        {
                            loc1 = loc3.physicalDefense;
                        }
                    }
                    else 
                    {
                        loc1 = loc3.physicalCrit;
                    }
                }
            }
            return loc1;
        }

        public static getAttrTypeArray(arg1: ItemData): Array<any>
        {
            var loc1=0;
            var loc3=null;
            var loc2=ItemConfig.instance.getInfoByCode(arg1.itemCode);
            var loc4=[];
            if (loc2) 
            {
                if (loc3 = loc2.extend as TItemWeapon) 
                {
                    if (loc3.agile > 0) 
                    {
                        loc4.push(EJewel._EJewelAgile);
                    }
                    if (loc3.block > 0) 
                    {
                        loc4.push(EJewel._EJewelBlock);
                    }
                    if (loc3.brains > 0) 
                    {
                        loc4.push(EJewel._EJewelBrains);
                    }
                    if (loc3.habitus > 0) 
                    {
                        loc4.push(EJewel._EJewelHabitus);
                    }
                    if (loc3.hit > 0) 
                    {
                        loc4.push(EJewel._EJewelHit);
                    }
                    if (loc3.jouk > 0) 
                    {
                        loc4.push(EJewel._EJewelJouk);
                    }
                    if (loc3.life > 0) 
                    {
                        loc4.push(EJewel._EJewelLife);
                    }
                    if (loc3.magicAttack > 0) 
                    {
                        loc4.push(EJewel._EJewelMagicAttack);
                    }
                    if (loc3.magicCrit > 0) 
                    {
                        loc4.push(EJewel._EJewelMagicCrit);
                    }
                    if (loc3.magicDefense > 0) 
                    {
                        loc4.push(EJewel._EJewelMagicDefense);
                    }
                    if (loc3.mana > 0) 
                    {
                        loc4.push(EJewel._EJewelMana);
                    }
                    if (loc3.pass > 0) 
                    {
                        loc4.push(EJewel._EJewelPass);
                    }
                    if (loc3.physicalAttack > 0) 
                    {
                        loc4.push(EJewel._EJewelPhysicalAttack);
                    }
                    if (loc3.physicalCrit > 0) 
                    {
                        loc4.push(EJewel._EJewelPhysicalCrit);
                    }
                    if (loc3.physicalDefense > 0) 
                    {
                        loc4.push(EJewel._EJewelPhysicalDefense);
                    }
                    if (loc3.power > 0) 
                    {
                        loc4.push(EJewel._EJewelPower);
                    }
                    if (loc3.relief > 0) 
                    {
                        loc4.push(EJewel._EJewelRelief);
                    }
                    if (loc3.speededUp > 0) 
                    {
                        loc4.push(EJewel._EJewelSpeededUp);
                    }
                    if (loc3.toughness > 0) 
                    {
                        loc4.push(EJewel._EJewelToughness);
                    }
                }
            }
            return loc4;
        }

        public static getHuntLevelName(arg1: TPetLifestyleHunt): string
        {
            var loc1=ColorConfig.instance.getItemColorString(arg1.level);
            return HTMLUtil.addColor(arg1.hunterName, loc1);
        }

        public static flyToJunWindowPoint(arg1: Object /* flash.display.BitmapData */, arg2: Object /* flash.geom.Point */, arg3: Object /* flash.geom.Point */, arg4: Function=null, ... rest): void
        {
            var bitmapData: Object /* flash.display.BitmapData */;
            var globalPoint: Object /* flash.geom.Point */;
            var toPoint: Object /* flash.geom.Point */;
            var callBackFun: Function=null;
            var rest: Array<any>;
            var juWindow: PetMingJuWindow;
            var flyEnd: Function;

            var loc1;
            flyEnd = null;
            bitmapData = arg1;
            globalPoint = arg2;
            toPoint = arg3;
            callBackFun = arg4;
            rest = rest;
            flyEnd = (arg1: Object /* flash.display.Bitmap */): void
            {
                if (arg1 && arg1.parent) 
                {
                    arg1.parent.removeChild(arg1);
                }
                if (callBackFun != null) 
                {
                    callBackFun(rest);
                }
                return;
            }
            juWindow = Cache.instance.petMing.juWindow;
            FlyToNavbarTool.flyToAnyPoint(bitmapData, globalPoint, juWindow.localToGlobal(toPoint), flyEnd);
            return;
        }

        public static showAddExpEffect(arg1: int): void
        {
            var loc1=Cache.instance.petMing.juWindow;
            var loc2=loc1.localToGlobal(new Object /* flash.geom.Point */(695, 435));
            NumAddEffect.playAddNum(arg1, loc2.x, loc2.y);
            return;
        }

        public static get discountActivePrice(): int
        {
            var loc1=Cache.instance.petMing.goldJuTime;
            if (loc1 <= 9) 
            {
                return Cache.instance.petMing.discountActivePrice[loc1];
            }
            return Cache.instance.petMing.discountActivePrice[9];
        }

        public static isSameType(arg1: ItemData, arg2: ItemData): Boolean
        {
            if (arg1 && arg2) 
            {
                if (ItemsUtil.isRedPetLifeStyle(arg1)) 
                {
                    return arg1.itemCode == arg2.itemCode;
                }
                return arg1.type == arg2.type;
            }
            return false;
        }
    }
